unit UReprocessamentoConta2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, URotinasBase, StdCtrls, DBCtrls, DB, ComCtrls, Buttons, ExtCtrls;

type
  TFReprocessamentoConta2 = class(TFRotinasBase)
    dsConta: TDataSource;
    dblConta: TDBLookupComboBox;
    Label1: TLabel;
    procedure BtnExecClick(Sender: TObject);
    procedure dblContaKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FReprocessamentoConta2: TFReprocessamentoConta2;

implementation

uses UGeral, UDmGestao;

{$R *.dfm}

procedure TFReprocessamentoConta2.BtnExecClick(Sender: TObject);
const
  ctProcedure =
    'EXECUTE PROCEDURE'#10+
    '  RE_PROCESSA_LANCAMENTO'#10+
    '  (%s, /*Empresa*/'#10+
    '   %s /*Conta*/)';

begin

  inherited;

  if dblConta.KeyValue <> null then
  begin

    executaSQL(Format(ctProcedure, ['NULL',
                                    VarToStr(dblConta.KeyValue)]));

  end else begin

    executaSQL(Format(ctProcedure, ['NULL',
                                    'NULL']));

  end;

  ShowMessage('Reprocessamento concluido com ucesso!');
  Close

end;

procedure TFReprocessamentoConta2.dblContaKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  fun_dblookup(Key, Shift, dblConta);
end;

procedure TFReprocessamentoConta2.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  FReprocessamentoConta2.Release;
  FReprocessamentoConta2 := Nil;
end;

end.
